package com.aya.activity.facade;

import com.aya.activity.core.model.Goods;
import com.aya.activity.core.model.Shop;
import com.aya.activity.goods.descend.Descend;
import com.aya.activity.goods.discount.Discount;
import com.aya.activity.shop.fullmoney.FullMoney;

import java.math.BigDecimal;

public class ActivityFacade {
    private Descend descend = new Descend();

    private Discount discount = new Discount();

    private FullMoney fullMoney = new FullMoney();
@Deprecated
    public BigDecimal discount(Goods goods, BigDecimal price) {
        return discount.activity(goods, price);
    }
    @Deprecated
    public BigDecimal descend(Goods goods, BigDecimal price) {
        return descend.activity(goods, price);
    }
    @Deprecated
    public <T>BigDecimal fullMoney(T shopId, Goods goods, BigDecimal price) {
        return fullMoney.activity(shopId,goods,price);
    }

    public BigDecimal activity(ActivitySupport activitySupport) {
        Shop shop = activitySupport.getShop();
        Goods goods = shop.getGoods(activitySupport.getUserId());
        BigDecimal descendMoney = descend.activity(goods, goods.getPrice());
        BigDecimal discountMoney = discount.activity(goods, descendMoney);
        BigDecimal fuMoney = fullMoney.activity(shop.getId(), goods, discountMoney);
        return fuMoney;
    }

    ActivitySupport activitySupport;
    ActivityFacade(ActivityFacadeBuilder builder) {
        descend.setGoodsDescend(builder.descendService);
        discount.setGoodsDiscount(builder.discountService);
        fullMoney.setGoodsFullMoney(builder.fullMoneyService);
    }


}
